import 'package:desktop_window/desktop_window.dart';
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:fusion_one/redux/states/index.dart';
import 'package:fusion_one/redux/store/index.dart';
import 'init.dart';
import 'route/router.dart';

void main() async {
  await init();

  runApp(const MyApp());
  Size size = await DesktopWindow.getWindowSize();
  await DesktopWindow.setMinWindowSize(Size(1280, 720));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return StoreProvider<AppState>(
        store: store,
        child: MaterialApp(
          title: 'FusionOne',

          // 路由管理
          onGenerateRoute: RouterTable.onGenerateRoute,
          // 路由表
          routes: RouterTable.routeTables,
          // 初始路由
          initialRoute: store.state.token == null
              ? RouterTable.loginPath
              : RouterTable.homePath,
          // 去除右上角debug标签
          debugShowCheckedModeBanner: false,
          theme:
              ThemeData(primarySwatch: Colors.deepPurple, fontFamily: '微软雅黑'),
        ));
  }
}
